package com.vilicode.controller;

import com.vilicode.bean.Post;
import com.vilicode.bean.PostType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

@Controller
public class PosTypeController {
  @RequestMapping("/postbytypeid")
    public String postBytypeID(PostType postype, HttpServletRequest request) {
      System.out.println("typeId:" + postype);
      Post post = new Post();
      Post post2 = new Post();
      post2.setPname("测试2");
      post2.setImage("https://upload-bbs.miyoushe.com/upload/2023/05/01/301189105/3b112fad1aa62dc2bda3a2fe64fe5643_7164836832745563443.jpg");
      post2.setDescription("测试2");
      post.setPname("测试");
      post.setImage("https://tse2-mm.cn.bing.net/th/id/OIP-C.uuMRp41SjL9ukaBDDBWz5wHaNK?rs=1&pid=ImgDetMain");
      post.setDescription("测试");
      List<Post> posts = new ArrayList<>();
      posts.add(post);
      posts.add(post2);
      request.setAttribute("posts", posts);
      postype.setPtname("计算机");
      request.setAttribute("postype", postype);

        return "postListByType";
    }

    @RequestMapping("/companyByPost")
    public String companyByPost(HttpServletRequest request) {
      Post post = new Post();
      Post post2 = new Post();
      Post post3 = new Post();
      Post post4 = new Post();
      Post post5 = new Post();
      post2.setPname("测试1");
      post2.setImage("https://upload-bbs.miyoushe.com/upload/2023/05/01/301189105/3b112fad1aa62dc2bda3a2fe64fe5643_7164836832745563443.jpg");
      post2.setDescription("测试");
      post.setPname("测试2");
      post.setImage("https://tse2-mm.cn.bing.net/th/id/OIP-C.uuMRp41SjL9ukaBDDBWz5wHaNK?rs=1&pid=ImgDetMain");
      post.setDescription("测试");
      post3.setPname("测试3");
      post3.setImage("https://p6.itc.cn/q_70/images03/20231227/671f1a789cfd49c18983bb245bed62fb.jpeg");
      post3.setDescription("测试");
      post4.setPname("测试4");
      post4.setImage("https://pic3.zhimg.com/v2-d605db6807925bd47ceb91ffd57e4df6_r.jpg");
      post4.setDescription("测试");
      post5.setPname("测试5");
      post5.setImage("https://ww4.sinaimg.cn/mw690/006qQN8Xgy1hl1ic6ik8mj31401hcn7c.jpg");
      post5.setDescription("测试");
      List<Post> posts = new ArrayList<>();
      posts.add(post);
      posts.add(post2);
      posts.add(post3);
      posts.add(post4);
      posts.add(post5);
      request.setAttribute("posts", posts);
    return "companyByPost";


    }
}
